package com.wesh.home.service.impl;

import com.wesh.home.dao.home.BannerDao;
import com.wesh.home.model.home.BannerDO;
import com.wesh.home.service.HomeService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HomeServiceImpl implements HomeService {

    @Resource
    BannerDao bannerDao;

    @Resource
    private RestTemplate restTemplate;

    @Value("${app.servers.userServer}")
    private String serverName;

    @Override
    public List<BannerDO> listBanners() {
        return bannerDao.listOfBanner();
    }

    @Override
    public String userInfo() {
        return restTemplate.getForObject("http://" + serverName + "/user/uInfo", String.class);
    }

}
